package com.dingyx.ps.util;

import com.dingyx.ps.model.vo.AccountVO;
import lombok.extern.slf4j.Slf4j;

/**
 * @author dingyuxin
 *
 */
@Slf4j
public class ThreadLocalUtil {

    /**
     * 用户信息
     */
    private static final ThreadLocal<AccountVO> USER = new ThreadLocal<>();

    /**
     * 设置用户信息
     *
     * @param account
     */
    public static void setAccount(AccountVO account) {
        USER.set(account);
    }

    /**
     * 获取用户账号信息
     *
     * @return
     */
    public static AccountVO getAccount() {
        AccountVO userVO = USER.get();
        return userVO;
    }

    /**
     * 清空所有ThreadLocal
     */
    public static void clear() {
        USER.remove();
    }
}
